#!/bin/bash

# setup.sh - 远程开发环境设置脚本
# 功能：安装必要的依赖库和locale字符集

echo "开始更新和升级系统包..."
sudo apt update && sudo apt upgrade -y

echo "开始安装依赖库和locale字符集..."

# 安装依赖库
echo "安装必须软件 - 报表初始化字体库..."
sudo apt-get install zip unzip xdg-utils libfreetype6 fontconfig rename -y

echo "安装图形依赖 - 安装盘..."
sudo apt-get install libxi6 libxtst6 libxrender1 libswt-gtk-4-java -y

echo "安装fd-find替代find..."
sudo apt install fd-find -y

echo "为所有用户将fdfind别名为fd..."
sudo ln -sf /usr/bin/fdfind /usr/bin/fd

# 安装locale字符集（系统输出中文文件名需要）
echo "安装locale字符集（支持中文文件名）..."
sudo apt install language-pack-zh-han* language-pack-en* -y

echo "安装完成！"
echo "请运行以下命令使locale设置生效："
echo "sudo locale-gen zh_CN.UTF-8"
echo "sudo update-locale LANG=zh_CN.UTF-8"

echo ""
echo "## 三、下载CLI（Linux）"
echo ""

echo "创建工作目录并下载项目..."
mkdir -p ~/projects # 创建工作目录
cd ~/projects

# git clone -b develop-ncc3.2 https://git.yyrd.com/guxgn/page.git
git clone -b main https://gitee.com/mozhuanzuojing/ncc-gradle-vscode.git

echo ""
echo "## 四、复制java开发配置（Linux）"
echo ""

echo "复制java开发配置..."
sudo mkdir -p /usr/local/java/config
cd /usr/local/java/config

sudo cp ~/projects/ncc-gradle-vscode/env/windows/Users/Administrator/AppData/Roaming/Code/User/*.prefs /usr/local/java/config # 复制java编译配置文件
sudo cp ~/projects/ncc-gradle-vscode/env/windows/Users/Administrator/AppData/Roaming/Code/User/vscode-java-google-style.xml /usr/local/java/config # 复制java格式化配置文件

sudo chmod ugo+w *  # 增加写权限

echo "查看配置..."
ls /usr/local/java/config # 查看配置

echo "配置完成！"